package com.inspur.jxpcxt.app;

import java.util.Stack;

import android.app.Activity;
import android.app.Application;
/**
 * 注册管理所有Activity
 * @author Administrator
 *
 */
public class JXPCApplication extends Application {
	private static Stack<Activity> atackActivities = null;
	//单列
	private static JXPCApplication singleton = null;
	public static JXPCApplication getInstance(){
		return singleton;
	}
	
	@Override
	public void onCreate()
		{
			// TODO Auto-generated method stub
			super.onCreate();
			singleton = this;
		}
	/**
	 * 将activity入栈
	 * @param activity
	 */
	public void addActivity(Activity activity){
			if(atackActivities == null){
				atackActivities = new Stack<Activity>();
			}
			atackActivities.add(activity);
	}
	/**
	 * 清空栈内的所有activity
	 */
	public void finishAllActivitys(){
			for(int i=0;i<atackActivities.size();i++){
				if(atackActivities.get(i) != null){
					atackActivities.get(i).finish();
				}
			}
			atackActivities.clear();
	}
}
